<?php

namespace App\Exceptions;

use Exception;
use function GuzzleHttp\Psr7\str;
use Throwable;

class ApiException extends Exception
{
    protected $message, $code;

    public function __construct($message = "", $code = 0, Throwable $previous = null)
    {
        $this->message = $message;
        $this->code = $code;
        parent::__construct($message, $code, $previous);
    }

    public function getResponseData()
    {
        $data['code'] = strval($this->code);
        $data['message'] = $this->message;
        return $data;
    }

    public function getStatusCode($statusCode = 500)
    {
        $statusCode = substr($this->code, 0, 3);
        return $statusCode;
    }
}
